from flask import Flask, request, jsonify, make_response
import os
import uuid

from flask_cors import CORS

app = Flask(__name__)

# 允许所有来源的跨域请求（不推荐在生产环境中使用）
CORS(app)

@app.route('/upload', methods=['POST'])
def upload_file():
    file = request.files['file']
    file_path = os.path.join('uploads',file.filename)
    file.save(file_path)  # 保存文件
    return make_response(jsonify({
        'file_id': file.filename,
        'message': 'File uploaded successfully',
        'status_code': 200
    }), 200)

if __name__ == '__main__':
    app.run(debug=False)